package com.example.makerspace.dto;

import com.example.makerspace.enums.ResultCodeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author River
 * @version 1.0
 * @date 2023/9/26 11:32
 * @description:
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result {
    protected long code;
    protected String message;
    protected Object obj;


    public static Result success(){
        return new Result(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), null);
    }


    public static Result success(Object obj){
        return new Result(ResultCodeEnum.SUCCESS.getCode(), ResultCodeEnum.SUCCESS.getMessage(), obj);
    }

    public static Result success(ResultCodeEnum respBeanEnum){
        return new Result(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    public static Result success(ResultCodeEnum respBeanEnum, Object obj){
        return new Result(respBeanEnum.getCode(), respBeanEnum.getMessage(), obj);
    }



    public static Result error(ResultCodeEnum respBeanEnum){
        return new Result(respBeanEnum.getCode(), respBeanEnum.getMessage(), null);
    }

    public static Result error(ResultCodeEnum respBeanEnum, Object obj){
        return new Result(respBeanEnum.getCode(), respBeanEnum.getMessage(), obj);
    }

}
